# -*- coding: UTF-8 -*-

import logging
import random

import datetime

# 定义需要爬取的网站
global websites
websites = {
    'bytravel': 'http://shop.bytravel.cn',
}

global websites_chs
websites_chs = {
    'bytravel': '博雅特产网',
}

# 定义代理链接
proxy_1 = {
  "http": "http://111.7.130.101:8080",
  "https": "http://111.7.130.101:8080",
}
proxy_2 = {
  "http": "http://39.137.69.10:8080",
  "https": "http://39.137.69.10:8080",
}
proxy_3 = {
  "http": "http://39.137.77.66:8080",
  "https": "http://39.137.77.66:8080",
}

# 定义伪装的headers
global accept_header
headers_1 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3"+str(random.randint(10, 99))+"7.100 Safari/537.36"+str(random.randint(10, 99))
}
headers_2 = {
    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/6"+str(random.randint(10, 99))+".1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/6"+str(random.randint(10, 99))+".1.4 (compatible; YandexBot/3.0; +http://yandex.com/bots)"
}
headers_3 = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/6"+str(random.randint(1, 9))+".0.3"+str(random.randint(10, 99))+"2.140 Safari/537.36 Edge/17.171"+str(random.randint(10, 99))
}

# mofcom 新农商网 爬取页面需要定义的头，否则返回rows字段中文乱码
accept_header = {
    "Accept": "application/json, text/javascript, */*; q=0.01"
}

# 休眠时间
global sleep_time
# 测试环境配置
# sleep_time = 0
# 生产环境配置
sleep_time = 0

# 日志级别
global log_level
log_level = logging.DEBUG
# log_level = logging.INFO

# 文件保存日志级别
global file_log_level
file_log_level = logging.DEBUG

# 日志文件保存位置
global log_file_path
log_file_path = "logs/log-"+datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")+".log"

# requests 重试次数
global requests_retry_times
requests_retry_times = 5

# MySQL数据库相关配置
mysql_host = "192.168.207.15"
mysql_port = 3306
mysql_user = "root"
mysql_password = "root"
mysql_db = "db_xl_bytravel_spider"
mysql_use_unicode = True
mysql_encode = "utf8"

# id_counts
global pro_id_count
pro_id_count = 1000
global dis_id_count
dis_id_count = 10000
global spe_id_count
spe_id_count = 100000